﻿using System;
using System.Collections.Generic;
using System.Linq;
using Informant.Services.Models.Contacts;
using Informant.SmsMessaging;
using Informant.Contacts;
using System.Runtime.Serialization;

namespace Informant.Services.Models.SmsMessaging
{
	[DataContract(Name = "Sms")]
	public class Sms : ISms
	{
		/// <summary>
		/// Gets or sets the Sms id.
		/// </summary>
		/// <value>The Sms id.</value>
		[DataMember]
		public String Id { get; set; }
		/// <summary>
		/// Gets or sets a value indicating whether this instance is read.
		/// </summary>
		/// <value><c>true</c> if this instance is read; otherwise, <c>false</c>.</value>
		[DataMember]
		public Boolean IsRead { get; set; }
		/// <summary>
		/// Gets or sets the messages.
		/// </summary>
		/// <value>The messages.</value>
		public IEnumerable<IMessage> Messages
		{
			get { return ServiceModelMessages.OfType<IMessage>(); }
			set { ServiceModelMessages = value.OfType<Message>(); }
		}
		/// <summary>
		/// Gets or sets the messages.
		/// </summary>
		/// <value>The messages.</value>
		[DataMember]
		public IEnumerable<Message> ServiceModelMessages { get; set; }
		/// <summary>
		/// Gets or sets the recipients.
		/// </summary>
		/// <value>The recipients.</value>
		public IEnumerable<IPhone> Recipients
		{
			get { return ServiceModelRecipients.OfType<IPhone>(); }
			set { ServiceModelRecipients = value.OfType<Phone>(); }
		}
		/// <summary>
		/// Gets or sets the recipients.
		/// </summary>
		/// <value>The recipients.</value>
		[DataMember]
		public IEnumerable<Phone> ServiceModelRecipients { get; set; }
		/// <summary>
		/// Gets the sender.
		/// </summary>
		/// <value>The sender.</value>
		public IPhone Sender
		{
			get { return ServiceModelSender; }
			set { ServiceModelSender = (Phone)value; }
		}
		/// <summary>
		/// Gets the sender.
		/// </summary>
		/// <value>The sender.</value>
		[DataMember]
		public Phone ServiceModelSender { get; set; }
	}
}
